package com.jixiantubu.util;

import com.baidu.mapapi.SDKInitializer;
import com.example.jixiantubu.R;
import com.jixiantubu.bean.Travelsbean;
import com.jixiantubu.bean.UserBean;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.HttpUtils;

import android.app.Application;

import android.content.Context;
import android.widget.Toast;

public class MyApplication extends Application {
	private static String IP = "10.204.1.46";
	// private static String IP = "172.29.254.1";
	 //private static String IP = "192.168.191.1";
	public static int pagenum = 5;
	static Travelsbean travelsbean;
	public static HttpUtils httpclient = new HttpUtils();// 异步网络请求
	// public static RequestParams params=new RequestParams();
	public static UserBean user = new UserBean();
	public static String user_id;
	 //public static String otherusername;
	public static BitmapUtils bitmapUtils;
	public static String username;

	@Override
	public void onCreate() {
		// application的onCreate只会调用一次，加之bitmapUtils是
		// static修饰的，表示所有对象共享
		bitmapUtils = new BitmapUtils(getApplicationContext());
		bitmapUtils.configDefaultLoadFailedImage(R.drawable.error);
		bitmapUtils.configDefaultLoadingImage(R.drawable.loding);
		super.onCreate();
		//在使用SDK各组件之前初始化context信息，传入ApplicationContext  
        //注意该方法要再setContentView方法之前实现  
        SDKInitializer.initialize(getApplicationContext());
	}

	public static void show(Context context, String text) {
		Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
	}

	public static Travelsbean getTravelsbean() {
		return travelsbean;
	}

	public static String getUsername() {
		return username;
	}

	public static void setUsername(String username) {
		MyApplication.username = username;
	}

	public static void setTravelsbean(Travelsbean travelsbean) {
		MyApplication.travelsbean = travelsbean;
	}

	public static String getIP() {
		return IP;
	}

	public static void setIP(String iP) {
		IP = iP;
	}

	// @Override
	// public void onCreate() {
	// super.onCreate();
	// /**
	// * OnCreate 会被多个进程重入，这段保护代码，确保只有您需要使用 RongIM 的进程和 Push 进程执行了 init。
	// * io.rong.push 为融云 push 进程名称，不可修改。
	// */
	//
	// mCache = ACache.get(this);
	// httpclient = new HttpUtils();
	// PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
	// httpclient.configCookieStore(myCookieStore);
	//
	// System.out.println("=========" + mCache.getAsObject("user"));
	// user = (UserBean) mCache.getAsObject("user");
	// // user=(User) mCache.getAsObject("user");
	// // System.out.println(mCache.getAsString("user1"));
	// }

	/*
	 * public static void saveLoginStatus(UserBean user) { MyApplication.user =
	 * user; mCache.put("user", user); System.out.println(user); }
	 */

	/**
	 * 获得当前进程的名字
	 * 
	 * @param context
	 * @return 进程号
	 */
	/*
	 * public static String getCurProcessName(Context context) {
	 * 
	 * int pid = android.os.Process.myPid();
	 * 
	 * ActivityManager activityManager = (ActivityManager) context
	 * .getSystemService(Context.ACTIVITY_SERVICE);
	 * 
	 * for (ActivityManager.RunningAppProcessInfo appProcess : activityManager
	 * .getRunningAppProcesses()) {
	 * 
	 * if (appProcess.pid == pid) { return appProcess.processName; } } return
	 * null; }
	 */

}
